<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>金字塔</title>
</head>
<body>
        <script>
                var level=prompt("请输入金字塔的层数");
                level=parseFloat(level) && Number(level);
                if(isNaN(level)){
                    alert("金字塔的层数必须是纯数字");
                }
                for(var i=1;i<=level;++i){
                    var blank=level-i;
                    document.write('&nbsp;'); 
                    var star=i*2-1;
                for(var j=0;j<star;++j){
                    document.write('*');
                }
                document.write('<br>');
                }
               
                
                </script>
            
</body>
</html>